package com.gxa.controller;

import com.gxa.common.base.RespResult;
import com.gxa.domain.entity.TransferRecord;
import com.gxa.domain.entity.User;
import com.gxa.service.TransferRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 万事顺意
 * Created with IntelliJ IDEA.
 * User: zwj
 * Date: 2024/07/2011:02
 * Description:
 */
@RestController
@RequestMapping("/transfer_record")
public class TransferRecordController {
    @Autowired
    private TransferRecordService transferRecordService;
    @GetMapping("/query")
   public RespResult query(Integer id){
        TransferRecord byId= transferRecordService.getById(id);
        return RespResult.success(byId);
    }

    @PostMapping("/save")
    public RespResult save(@RequestBody TransferRecord transferRecord){
        boolean save= transferRecordService.save(transferRecord);
        if (save){
            return RespResult.success(save);
        }
        return RespResult.error("添加失败");
    }
    @PostMapping("/update")
    public RespResult update(TransferRecord transferRecord){
        boolean b= transferRecordService.updateById(transferRecord);
        if (b){
            return RespResult.success(b);
        }
        return RespResult.error("修改失败");
    }
    @PostMapping("/delete")
    public RespResult delete(Integer id){
        boolean b= transferRecordService.removeById(id);
        if (b){
            return RespResult.success(b);
        }
        return RespResult.error("删除失败");
    }
    @GetMapping("/list")
    public RespResult list1(){
        List<TransferRecord> list= transferRecordService.list();
        return RespResult.success(list);
    }
}
